package com.bjpowernode.singleton;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName Singleton04
 *
 * @Author Cat
 */
public final class Singleton04 {

    private static Singleton04 instance = null;

    public String data;

    private Singleton04() {
        try {
            TimeUnit.MILLISECONDS.sleep(5);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        this.data = "要初始化的数据";
        //连接zookeeper，连接redis......
    }

    public static Singleton04 getInstance() {
        if (null == instance) {
            synchronized (Singleton04.class) {
                if (null == instance) {
                    instance = new Singleton04();
                }
            }
        }
        return instance;
    }
}